<template>
    <el-card shadow="never" style="border: 0;">
        <yun-form
            :data="row"
            @submit="onSubmit"
            ref="yunForm"
            :tabs="['基础信息','业务信息']"
            :columns="columns">
            <template #default>
                {:token_field()}
            </template>
            <template v-slot:third_id="{rows}">
                <el-form-item label="绑定微信:">
                    <third :value="rows.third_id" :multiple="true" :selectable="false" @change="changValue"></third>
                </el-form-item>
            </template>
        </yun-form>
    </el-card>
</template>
<script>
import form from "@components/Form.js";
import third from "@components/Third.js";
export default{
    components:{
        'YunForm':form,
        'Third':third
    },
    data:{
        columns:[
            {field:"merch_name",tab:0,title:"商户名称",edit:"text",rules:"required"},
            {field:"phone",tab:0,title:"商户电话",edit:"text"},
            {field:"username",tab:0,title:"用户名",edit:{form:'input',type:'text',prepend:Yunqi.data.uniqid+'-'},rules:"required"},
            {field:'password',tab:0,title:'密码',edit:{form:'input',type:'password'},rules:(Yunqi.config.action=='add')?'required':''},
            {field:'third_id',tab:0,title:'绑定微信',edit:{form:'slot',name:'third_id'},rules:'required'},
            {field:"is_self",tab:0,title:"自营商户",searchList:{'1':'是','0':'否'},edit:{form:'radio',value:'0'}},
            {field:"status",tab:0,title:"启用状态",searchList:{'normal':'是','hidden':'否'},edit:{form:'radio',value:'normal'}},
            {field:"coupon",tab:1,title:"支持减免类型",edit:"checkbox",rules:"required",searchList:Yunqi.data.coupon},
            {field:"settle_type",tab:1,title:"结算方式",edit:{form:'select',disabled:(Yunqi.config.action=='add')?false:true},rules:"required",searchList:Yunqi.data.settleType},
            {field:"price",tab:1,title:"单位价格",edit: {form:'input',type:'number',append:'元/小时'},rules:"range(0~)",visible:function (row){
                return row.settle_type=='time';
            }},
            {field:"price_time",tab:1,title:"累加时间",edit: {form:'input',type:'number',append:'分钟'},rules:"range(0~)",visible:function (row){
                return row.settle_type=='time';
            }},
            {field:"allow_arrears",tab:1,title:"允许最多欠费",edit: {form:'input',type:'number',append:'元'},rules:"required",visible:function (row){
                return row.settle_type!='time';
            }},
            {field:"discount",tab:1,title:"折扣",edit: {form:'input',type:'number',append:'折',placeholder:'不填，填0，填10表示不打折'},rules:"range(0~10)"},
            {field:"static_able",tab:1,title:"允许静态码",searchList:{'1':'是','0':'否'},edit: 'radio',rules:"required"},
            {field:"static_expire",tab:1,title:"静态码有效期",edit: {form:'input',type:'number',append:'天',value:7},rules:"required,integer,range(1~)",visible:function (row){
                return row.static_able=='1';
            }},
            {field:"day_shenhe",tab:1,title:"预约车授权",searchList:Yunqi.data.day,edit:'checkbox',visible:function (row){
                let keys=Object.keys(Yunqi.data.day);
                return keys.length>0;
            }},
            {field:"online_recharge",tab:1,title:"支持在线充值",searchList:{'1':'是','0':'否'},edit:{form:'radio',value:'1'},rules:"required",},
        ],
        row:Yunqi.data.row || {settle_type:'before',price:4,price_time:30,allow_arrears:0,third_id:[],static_able:0}
    },
    methods: {
        onSubmit:function (data){
            return true;
        },
        changValue:function (e){
            this.$refs.yunForm.setValue('third_id',e);
        }
    }
}
</script>
<style>
</style>